﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" StylesheetTheme="SkinFile" 
CodeBehind="BonusPromotions.aspx.cs" Inherits="Nivdal.BonusPromotions" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadPlaceHolder" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PageNamePlaceHolder" runat="server">
        <asp:Label ID="PageNameLabel" runat="server" CssClass="PageNameContentStyle" Text="<%$ Resources:Resource, BonusPromotions_PageName %>"></asp:Label>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate> 
        <div class="basic_element">
        <div class="red_title">
           <asp:Label ID="PageTitleLabel" runat="server" CssClass="white_title" Text="<%$ Resources:Resource, BonusPromotions_PageName %>"></asp:Label>
           
        </div>
        <div class="padding5">
        <asp:Panel ID="BonusPromotionsVisible" runat="server">
        <asp:Panel ID="PromotionsOpenPanel" runat="server">
            <asp:Label ID="SignupStatusLabel" runat="server" SkinID="GridLabel"></asp:Label>
            <br />
            <asp:Button ID="SignupButton" runat="server" Text="<%$ Resources:Resource, BonusPromotions_SignupForPromotion %>"
             message="<%$ Resources:Resource, BonusPromotions_AreYouSureSignUp %>"
             OnClick="SignupClick" OnClientClick='return confirm(this.getAttribute("message"))' 
             CssClass="GreenButtonTextStyle"  />
            <div style="height:20px;">
            <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                <ProgressTemplate>
                    <img src="Images/ajax-loader.gif" alt="" />
                </ProgressTemplate>
            </asp:UpdateProgress>
            </div>
        </asp:Panel>           
        <h1><asp:Label ID="PromotionsInfoTitleLabel" runat="server" Text="<%$ Resources:Resource, BonusPromotions_CountryInfoTitleLabelText %>" SkinID="InfoLabel"></asp:Label></h1>
        <asp:HyperLink ID="CountryHyperlink" runat="server" SkinID="GreenTitleHyperLink"></asp:HyperLink>
        <asp:GridView ID="BonusPromotionsGridView" runat="server" DataSourceID="BonusPromotionCountryInfoDataSource"
         SkinID="Professional" AutoGenerateColumns="false" AllowPaging="false">
        <Columns>
            <asp:TemplateField>
            <ItemTemplate>
                <asp:Label ID="PromotionLevelTextLabel" runat="server" SkinID="GridLabel" 
                Text='<%# Resources.Resource.BonusPromotions_PromotionToText + " "  + Eval("Level") %>'></asp:Label>
            </ItemTemplate>        
            </asp:TemplateField>
            <asp:TemplateField>
            <ItemTemplate>
                <asp:Label ID="NumTeamsLabel" runat="server" SkinID="GridLabel" 
                Text='<%#  Eval("NumPromotionPlaces") %>'></asp:Label>
            </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        </asp:GridView>

        <asp:SqlDataSource ID="BonusPromotionCountryInfoDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_BonusPromotionGetCountryStatus" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        
        <br /><br />
        <asp:Repeater ID="LevelsRepeater" runat="server" DataSourceID="LevelsDataSource">
        <ItemTemplate>
            <asp:HiddenField ID="LevelHiddenField" runat="server" Value='<%# Eval("LevelNum") %>' />
            <asp:HiddenField ID="CountryHiddenField" runat="server" Value='<%# Eval("CountryId") %>' />
            <asp:Label ID="SignedForPromotionTitleLabel" runat="server" SkinID="InfoLabel"
            Text="<%$ Resources:Resource, BonusPromotions_SignedForPromotionToLevel %>"></asp:Label>
            <asp:Label ID="LevelNumLabel" runat="server" Text='<%# Eval("LevelNum") %>' SkinID="InfoLabel"></asp:Label>
            <br />
            <asp:GridView ID="PromotionTeamsGridview" runat="server" AutoGenerateColumns="false" DataSourceID="PromotionsDataSource"
             SkinID="Professional" AllowPaging="false">
             <PagerSettings FirstPageText="<%$ Resources:Resource, FirstPage %>" LastPageText="<%$ Resources:Resource, LastPage %>"
                    Mode="NumericFirstLast" PageButtonCount="10" Position="Bottom" />
             <PagerStyle CssClass="pagination" HorizontalAlign="Center" />
             <Columns>                
                <asp:TemplateField ItemStyle-Width="3%">
                    <HeaderTemplate>
                        <asp:Label ID="GroupRankHeader" runat="server" Text="<%$ Resources:Resource, BonusPromotions_RankingGroupAbbreviation %>"
                         ToolTip="<%$ Resources:Resource, BonusPromotions_RankingGroup %>"></asp:Label>    
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="NumberLabel" runat="server" Text='<%# Eval("RankingGroup") %>' SkinID="GridLabel" ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ItemStyle-Width="3%">
                    <HeaderTemplate>
                        <asp:Label ID="RankInGroupHeaderLabel" runat="server" Text="#" ToolTip="<%$ Resources:Resource, BonusPromotions_RankInsideGroup %>"></asp:Label>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="RankLabel" runat="server" Text='<%# GetOrderInRank(Eval("LevelNum"), Eval("RankingGroup")) %>' SkinID="GridLabel"></asp:Label>
                    </ItemTemplate>                
                </asp:TemplateField>
                <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Team %>" ItemStyle-Width="27%">
                    <ItemTemplate>
                        <asp:HyperLink ID="TeamHyperlink" runat="server" SkinID="GreenTitleHyperLink"
                         NavigateUrl='<%# "~/TeamHomePage.aspx?TeamId=" + Eval("TeamId") %>'
                         Text='<%# Eval("TeamName") %>'></asp:HyperLink>
                    </ItemTemplate>                    
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="<%$ Resources:Resource, BonusPromotions_PositionTitle %>" ItemStyle-Width="10%">
                    <ItemTemplate>
                        <asp:Label ID="PositionLabel" runat="server" Text='<%# Eval("CurrentLeaguePosition") %>' SkinID="GridLabel"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Points %>" ItemStyle-Width="10%">
                    <ItemTemplate>
                        <asp:Label ID="PointsLabel" runat="server" Text='<%# Eval("Points") %>' SkinID="GridLabel"></asp:Label>
                    </ItemTemplate>                
                </asp:TemplateField>
                <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Goals %>" ItemStyle-Width="10%">
                    <ItemTemplate>
                        <asp:Label ID="GoalsLabel" runat="server" SkinID="GridLabel"
                         Text='<%# Eval("GoalsScored") + " - " + Eval("GoalsAgainst") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_League %>" ItemStyle-Width="37%">
                    <ItemTemplate>
                        <asp:HyperLink ID="LeagueHyperlink" runat="server" SkinID="GreenTitleHyperLink"
                         NavigateUrl='<%# "~/league.aspx?LeagueId=" + Eval("LeagueId")  %>'
                         Text='<%# Eval("LeagueName") %>'></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
             </Columns>
             <EmptyDataTemplate>
                 <asp:Label ID="NoSignedTeamsLabel" runat="server" Text="<%$ Resources:Resource, BonusPromotionsNoTeamsLabel %>" SkinID="GridLabel"></asp:Label>
             </EmptyDataTemplate>
            </asp:GridView>
            <asp:SqlDataSource ID="PromotionsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_BonusPromotionGetParticipants" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:ControlParameter ControlID="LevelHiddenField" Name="Level" Type="Decimal" PropertyName="Value" />
                    <asp:ControlParameter ControlID="CountryHiddenField" Name="CountryId" Type="Decimal" PropertyName="Value" />
                </SelectParameters>
            </asp:SqlDataSource>
        </ItemTemplate>
        <SeparatorTemplate>
            <br /><br />
        </SeparatorTemplate>
        </asp:Repeater>

        <asp:SqlDataSource ID="LevelsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="Nivdal_GetLeagueLevels" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        </asp:Panel>
        <asp:Panel ID="BonusPromotionsInvisible" runat="server">
            <asp:Label ID="BobusPromoInvisibleLabel" runat="server" Text="<%$ Resources:Resource, BonusPromotions_InfoUnavailable %>" SkinID="GridLabel"></asp:Label>
        </asp:Panel>
    </div>
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
    
</asp:Content>

